import unittest
from alg import Solution
from gen import generate_test_cases


class TestLargestNumber(unittest.TestCase):
    def test_example_cases(self):
        sol = Solution()

        # 测试示例用例
        test_cases = [
            ([10, 2], "210"),
            ([3, 30, 34, 5, 9], "9534330"),
            ([0, 0], "0"),
            ([1], "1"),
            ([10], "10")
        ]

        for nums, expected in test_cases:
            with self.subTest(nums=nums):
                result = sol.largestNumber(nums)
                print(f"输入: {nums}, 输出: {result}")
                self.assertEqual(result, expected)

    def test_generated_cases(self):
        sol = Solution()
        test_cases = generate_test_cases(5)

        for nums in test_cases:
            with self.subTest(nums=nums):
                result = sol.largestNumber(nums)
                print(f"输入: {nums}, 输出: {result}")
                # 验证结果是否为合法的非负整数字符串
                self.assertTrue(result.isdigit())
                if result != "0":
                    self.assertFalse(result.startswith('0'))


if __name__ == '__main__':
    unittest.main(verbosity=2)